#!/bin/bash
# run gmm_swiglu_quant atk automaticlly
VAR_NAME="ASCEND_HOME_PATH"
# 获得 环境变量中 ASCEND_HOME_PATH 的值
eval "VAR_VALUE=\${${VAR_NAME}}"
ASCEND_HOME_PATH=$(dirname ${VAR_VALUE})
echo "CANN 包路径${VAR_NAME} 的值为: ${ASCEND_HOME_PATH}"
# 获得 当前run.sh 文件所在目录 的路径
SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_PATH_DIR=$(dirname ${SCRIPT_PATH})
echo "当前脚本的绝对路径: $SCRIPT_PATH_DIR"

RUN_TASK_NUM=200
REGEN_JSON="false"


source ${ASCEND_HOME_PATH}/set_env.sh

run_atk() {
    if [ ! -f "result/aclnnGroupedMatmulSwigluQuant/json/all_aclnnGroupedMatmulSwigluQuant.json" -o ${REGEN_JSON}=="true" ]; then
        # 生成模型用例
        atk case -f aclnnGroupedMatmulSwigluQuant_model.yaml -p ascend_generate_grouped_matmul_swiglu_quant_model.py
        # 生成泛化用例
        atk case -f aclnnGroupedMatmulSwigluQuant.yaml -p ascend_generate_grouped_matmul_swiglu_quant.py
    fi
    # 执行模型用例
    atk node --backend pyaclnn --devices 0 node --backend cpu task -c result/aclnnGroupedMatmulSwigluQuant_model/json/all_aclnnGroupedMatmulSwigluQuant_model.json --task accuracy -p function_aclnn_grouped_matmul_swiglu_quant.py
    # 执行泛化用例
    atk node --backend pyaclnn --devices 0 node --backend cpu task -c result/aclnnGroupedMatmulSwigluQuant/json/all_aclnnGroupedMatmulSwigluQuant.json --task accuracy -p function_aclnn_grouped_matmul_swiglu_quant.py -e ${RUN_TASK_NUM}
}

# # run atk
cd ${SCRIPT_PATH_DIR}
run_atk

echo ""
echo "#####################################"
echo "GMMSwigluQuant ATK TEST FINISHED"
echo "#####################################"
echo ""